<template>
	<view v-if="huodong_data_list_cuozuo == 1" class="d-kuan">
		<view class="d-kuan d-shang-10">
				<view class="d-kuan " style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
					<view class="d-wenzi-16 d-you-10 d-jiacu">{{ huodong_data_list.title }}</view>
				</view>

			
				<view class="d-kuan d-yuanjiao-10 d-shang-10" style="background-color: #fff6f6;">
					<view class="d-neikuang-10 ">
						<view class="d-kuan">
							<view class="d-zuo">
								<view class="d-wenzi-18 d-jiacu d-zitiyanse-hongse" >活动</view>
							</view>
							<view class="d-you">
								<view v-if="huodong_data_list.hdfw ==1" class="d-wenzi-18 d-jiacu d-zitiyanse-hongse">@本圈子</view>
								<view v-else class="d-wenzi-18 d-jiacu d-zitiyanse-hongse" >@所有人</view>
							</view>
						</view>
						<view class="d-kuan " style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
							<view class="d-wenzi-16 d-you-10">只剩</view>
							<view class="d-zitiyanse-hongse" style="font-size: 40px; line-height: 40px;">{{ huodong_data_list.shengyu_renshu}}</view>
							<view class="d-wenzi-16 d-zuo-10">位名额</view>
						</view>
						<view class="d-kuan d-shang-10" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
							<view v-if="huodong_data_list.hdfs == 1">
								<view class="d-wenzi-14 d-you-10">线下免费</view>
							</view>
							<view v-else-if="huodong_data_list.hdfs == 2" style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
								<view class="d-wenzi-14 d-you-10">线下付费</view><view class="d-wenzi-14 d-you-10 " style="">¥ {{ huodong_data_list.hdfy }} 元</view>
							</view>
							<view v-else-if="huodong_data_list.hdfs == 3">
								<view class="d-wenzi-14 d-you-10">线上免费</view>
							</view>
							<view v-else-if="huodong_data_list.hdfs == 4"  style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
								<view class="d-wenzi-14 d-you-10">线上付费</view><view class="d-wenzi-14 d-you-10 " style="">¥ {{ huodong_data_list.hdfy }} 元</view>
							</view>
							<view v-else-if="huodong_data_list.hdfs == 5"  style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
								<view class="d-wenzi-14 d-you-10">线上积分</view><view class="d-wenzi-14 d-you-10 " style="">{{ huodong_data_list.huodongjifen }} 积分</view>
							</view>


							

						</view>

						<view class="d-kuan d-shang-10" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
							<view v-if="huodong_data_list.baoming==0" class="d-wenzi-16 d-you-10">
								<uv-button v-if="huodong_data_list.yiman == 0" @click="hd_baoming" type="primary" icon="map" shape="circle" text="立即报名"
								    color="linear-gradient(to right, rgb(221, 25, 255), rgb(255, 102, 102))"
								></uv-button>
								<uv-button v-else type="primary" icon="map" shape="circle" text="已经结束"
								    color="linear-gradient(to right, rgb(221, 25, 255), rgb(255, 102, 102))"
								></uv-button>
                                <!--点击按钮-->
							</view>
							<view v-if="huodong_data_list.baoming==1" class="d-wenzi-16 d-you-10">
								
								<uv-button v-if="huodong_data_list.hdtc==0" type="primary" icon="checkbox-mark" shape="circle" text="报名成功"
								    color="linear-gradient(to right, rgb(12, 172, 189), rgb(30, 174, 218))"
								></uv-button>
								<uv-button v-if="huodong_data_list.hdtc==1" @click="huodong_tuichu" type="primary" icon="checkbox-mark" shape="circle" text="报名成功 | 可退出"
								    color="linear-gradient(to right, rgb(12, 172, 189), rgb(30, 174, 218))"
								></uv-button>
							</view>
						</view>
						<view class="d-kuan d-shang-10" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
							<view class="d-wenzi-16 d-zuo-10">本次活动共 <text style="color: #ff783a;">{{ huodong_data_list.hdrs }}</text> 位名额</view>
						</view>
						<view class="d-kuan d-shang-10" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
							<view class="d-wenzi-16 d-zuo-10">开始 {{ huodong_data_list.hdks }} 至 {{ huodong_data_list.hdjs }} 结束</view>
						</view>
						<view class="d-kuan d-shang-20" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
                            <!--shengyu_shijian_expr 24 * 60 * 60 * 1000-->
							<!--uv-count-down 
								:time="huodong_data_list.shengyu_shijian_expr" 
								format="DD:HH:mm:ss" 
								autoStart 
								millisecond 
								@change="onChange">
								<view class="time">
									<text class="time__item">{{ timeData.days }} 天 </text>
									<text class="time__item d-zuo-5">{{ timeData.hours> 10?timeData.hours:'0'+timeData.hours}} 时</text>
									<text class="time__item d-zuo-5">{{ timeData.minutes }} 分</text>
									<text class="time__item d-zuo-5">{{ timeData.seconds }} 秒</text>
								</view>
							</uv-count-down-->
						</view>
						<view class="d-kuan d-shang-10" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
											<uv-steps :current="huodong_data_list.hd_js" active-color="#ff6208" inactive-color="#e6dfdf">
												<uv-steps-item bgcolor="#fff7f7"  title="开始" >

												</uv-steps-item>
												<uv-steps-item bgcolor="#fff7f7"  title="进行中" >

												</uv-steps-item>
												<uv-steps-item bgcolor="#fff7f7" title="结束" >

												</uv-steps-item>
											</uv-steps>

						</view>

						<view class="d-clear"></view>
					</view>

				</view>
			<!--充值-->
			<view v-if="uid" class="d-kuan d-clear d-shang-10 d-xia-10">
				<view class="d-zuo">
					<text class="d-zuo d-wenzi-12" style="color: #dc500e;">你的积分：{{ uid_data.score }} </text>
				</view>
				<view class="d-you">
					<text class="d-zuo d-wenzi-12" style="color: #dc500e;">余额：{{ uid_data.money }}</text>
					<uv-icon @click="show_zhifu" name="red-packet" label="充值 " class="d-zuo-10 d-you"></uv-icon>
				</view>
			
			</view>


			

		</view>
		<uv-overlay :show="hd_baoming_show" @tap="hd_baoming_close" zIndex="998" opacity="0">
			<view class="warp_baoming">
				<view class="rect_baoming" @tap.stop.prevent>
					<view class="d-kuan d-clear">
						
						<view class="d-you">
							<uv-icon @click="hd_baoming_close" name="close" label="关闭 " class="d-zuo-10 d-you"></uv-icon>
						</view>

					</view>
					<view class="d-kuan d-clear d-shang-10 d-xia-10">
						<view class="d-juzhong">
							<text class="d-wenzi-18 d-jiacu" style="color: #dc500e;" >报名活动</text>
						</view>
					</view>
					<view class="d-kuan d-shang-10 d-clear" style="text-align: center; white-space: nowrap; display: flex; justify-content: center; align-items: flex-end;">
						<view v-if="huodong_data_list.hdfs == 1">
							<view class="d-wenzi-14 d-you-10">线下免费</view>
						</view>
						<view v-else-if="huodong_data_list.hdfs == 2" style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
							<view class="d-wenzi-14 d-you-10">线下付费 支付 </view><view class="d-wenzi-14 d-you-10 " style="">¥ {{ huodong_data_list.hdfy }} 元</view>
						</view>
						<view v-else-if="huodong_data_list.hdfs == 3">
							<view class="d-wenzi-14 d-you-10">线上免费</view>
						</view>
						<view v-else-if="huodong_data_list.hdfs == 4"  style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
							<view class="d-wenzi-14 d-you-10">线上付费 支付 </view><view class="d-wenzi-14 d-you-10 " style="">
								¥ {{ huodong_data_list.hdfy }} 元 * {{ fenliang }} 份 = {{ huodong_data_list.hdfy * fenliang }} 元
							</view>
						</view>
						<view v-else-if="huodong_data_list.hdfs == 5"  style="display: flex; justify-content: center; white-space: nowrap;font-size: 14px;color: #d65215;">
							<view class="d-wenzi-14 d-you-10">线上积分 消费 </view><view class="d-wenzi-14 d-you-10 " style="">
								{{ huodong_data_list.huodongjifen }} 积分 * {{ fenliang }} 份 = {{ huodong_data_list.huodongjifen * fenliang }} 积分
							</view>
						</view>
				
					</view>
					<uv-input v-if="huodong_data_list.hdwxh == 1"  class="d-xia-10 d-shang-10" placeholder="微信号" border="surround" v-model="huodong_baoming_data_add.weixinhao" >
                        <template v-slot:prefix>
                            <uv-text
                                text="微信号"
                                margin="0 10px 0 0"
                                type="tips"
                            ></uv-text>
                        </template>
                    </uv-input>
                    <!-- 手机号 / shoujihaoma -->
                    <uv-input v-if="huodong_data_list.hdsjh == 1" class="d-shang-10" placeholder="手机号" border="surround" v-model="huodong_baoming_data_add.shoujihaoma">
                        <template v-slot:prefix>
                            <uv-text
                                text="手机号"
                                margin="0 10px 0 0"
                                type="tips"
                            ></uv-text>
                        </template>
                    </uv-input>
					<!-- 选选项 车牌号 / cph-->
					<uv-input v-if="huodong_data_list.cph == 1" class="d-shang-10" placeholder="车牌号" border="surround" v-model="huodong_baoming_data_add.cph">
                        <template v-slot:prefix>
                            <uv-text
                                text="车牌号"
                                margin="0 10px 0 0"
                                type="tips"
                            ></uv-text>
                        </template>
                    </uv-input>
					<view class="d-kuan d-clear">
						<uv-form :model="huodong_baoming_data_add" :rules="rules" ref="form">
							<uv-form-item :label="'每人可以参与'+huodong_data_list.xzrs+'份'" labelWidth="300rpx" prop="ke">
							    <!-- 移除max属性，通过代码逻辑控制最大值 -->
							    <uv-number-box v-model="huodong_baoming_data_add.xzrs" :min="1" :max="huodong_data_list.xzrs" @change="renshu_panduan"></uv-number-box>				
							</uv-form-item>

						</uv-form>

					</view>
					<!-- 选选项 身份证 / sfz-->
					<view v-if="huodong_data_list.sfz == 1" class="d-shang-10 ">
						<view class="">
							<!--view class="d-kuan d-wenzi-14 d-xia-10">
							   <view class="d-zuo"></view><view class="d-you" @click="sfz_tianjia">+添加</view>
							</view-->
							<!-- 动态渲染身份证组 -->
                            <view class="d-kuan d-sfz-gao" id="d-gundong" >
								<view 
									v-for="(item, index) in huodong_baoming_data_add.sfz" 
									:key="index"
									class="d-kuan d-yuanjiao-10 mb-10 " 
									:id="'sfz_id_' + index" 
									style="background-color: #f5f5f5; margin-bottom: 10px;"
									>
									<view class="d-neikuang-10">
										<view class="d-neikuang-10">
											<view class="d-zuo">{{'第' + (index + 1) + '份'}}</view>
											<view class="d-you" @click="sfz_shanchu(index)">-删除</view>
										</view>
										<view class="d-clear"></view>
										<uv-input placeholder="名称" class="d-shang-10"  border="surround" v-model="item[1]" >
										    <template v-slot:prefix>
										    	<uv-text
										    		text="名称"
										    		margin="0 10px 0 0"
										    		type="tips"
										    	></uv-text>
										    </template>
										</uv-input>
										<uv-input placeholder="身份证号" class="d-shang-10"  border="surround" v-model="item[2]" >
										    <template v-slot:prefix>
										    	<uv-text
										    		text="身份证号"
										    		margin="0 10px 0 0"
										    		type="tips"
										    	></uv-text>
										    </template>
										</uv-input>
									</view>
								</view>
							</view>
						</view>

                    </view>


					<uv-button class="d-shang-10 d-clear" color="linear-gradient(to right, rgb(221, 25, 255), rgb(255, 102, 102))" shape="circle" type="primary" text="立即报名" @click="postHuodong_baoming_add_api" ></uv-button>
				</view>
			</view>
		</uv-overlay>
		<!--报名列表-->
		<view v-if="huodong_data_list.uid == uid" class="d-kuan d-clear">
			<view class="d-you">
				<!--按钮-->
				<uv-button class="d-shang-10 d-clear" size="small" color="linear-gradient(to right, rgb(221, 25, 255), rgb(255, 102, 102))" shape="circle" type="primary" text="报名列表" @click="baoming_uid_list_api(huodong_data_list.hd_id)" ></uv-button>
			</view>
		</view>
	</view>
</template>

<script>
import HuodongApi from '@/utils/huodong_api.js';
import { getRequest,postRequest } from '@/utils/wxRequest.js';
	export default {
		props: {
			huodong_data_list_cuozuo: {
				type: Number,
				default: 0,
			},
			huodong_data_list: {
				type: Object,
				default: () => {},
			},
			uid_data: {
				type: Object,
				default: () => {},
			},
			id: {
				type: [String, Number],
				default: 0,
			},
			cid: {
				type: [String, Number],
				default: 0,
			},
			
		},

		data() {
			return {
				//huodong_data_list_cuozuo: 1,
				timeData: {},
				hd_baoming_show: false,
				huodong_baoming_data_add:{
					xzrs: 1, // 默认选择1份
					sfz: [] // 身份证信息数组
				},
				fenliang:1,//份数
			}
			
		},
		computed: {
			keycode() {
			  return $store.state.keycode;
			},
			uid() {
			  return this.$store.state.memberuid;
			},
		},
		methods: {
			// 人数判断
			renshu_panduan(e){
				this.fenliang = e.value; //份量
				// 确保e和e.value存在，避免潜在的undefined错误
				if(e && e.value !== undefined){
					// 检查是否超过最大允许数量
					if(e.value >= this.huodong_data_list.xzrs){
						// 显示提示信息
						uni.showToast({
							title: '最多只能参与'+this.huodong_data_list.xzrs+'份',
							icon: 'none',
							duration: 2000
						})
						// 将值重置为最大值
						this.huodong_baoming_data_add.xzrs = this.huodong_data_list.xzrs;
					} else {
						// 正常选择范围内的值
						this.huodong_baoming_data_add.xzrs = e.value;
					}
					
					// 根据选择的数量添加或删除身份证分量
					if(this.huodong_baoming_data_add.sfz){
						const currentCount = this.huodong_baoming_data_add.sfz.length;
						const targetCount = this.huodong_baoming_data_add.xzrs;
						
						// 如果当前数量少于目标数量，添加新的身份证分量
						if(currentCount < targetCount){
							for(let i = currentCount; i < targetCount; i++){
								// 初始化新的身份证信息项
								this.huodong_baoming_data_add.sfz.push([i, '', '']);
							}
						}
						// 如果当前数量多于目标数量，删除多余的身份证分量
						else if(currentCount > targetCount){
							this.huodong_baoming_data_add.sfz.splice(targetCount);
						}
					}
				}
			},
			onChange(e) {
				this.timeData = e
			},
			// 显示充值弹窗
            show_zhifu(){
			  //this.show = true;
			  // 传值到父组件
			  //console.log('传值到父组件');
			  this.$emit('zhifu_show',true);
			},
			// 报名
            hd_baoming(){
				let uid = this.$store.state.memberuid;
				let code = this.$store.state.keycode;
				// 检查是否已登录
				if (!uid || !code) {
					uni.showToast({
						icon: 'none',
						title: '请先登录',
						duration: 1000
					});
					this.$emit('denglu-fabu');
					return;
				}
				this.hd_baoming_show = true;
            },
			// 报名关闭
			hd_baoming_close(){
				this.hd_baoming_show = false;
			},
			//报名
			async postHuodong_baoming_add_api(){
				
				let uid = this.$store.state.memberuid;
				let code = this.$store.state.keycode;
				// 检查是否已登录
				if (!uid || !code) {
					uni.showToast({
						icon: 'none',
						title: '请先登录',
						duration: 1000
					});
					return;
				}
				let cid = this.huodong_data_list.hd_id;
				let url = HuodongApi.postHuodong_shenqing_api(uid,code,cid);
				if(this.huodong_data_list.hdwxh == 1){
					if(!this.huodong_baoming_data_add.weixinhao){
						uni.showToast({
							title: '请输入微信号',
							icon: 'none'
						})
						return;
					}
				}
				if(this.huodong_data_list.hdsjh == 1){
					if(!this.huodong_baoming_data_add.shoujihaoma){
						uni.showToast({
							title: '请输入手机号',
							icon: 'none'
						})
						return;
					}
				}
				//车牌号
				if(this.huodong_data_list.cph == 1){
					if(!this.huodong_baoming_data_add.cph){
						uni.showToast({
							title: '请输入车牌号',
							icon: 'none'
						})
						return;
					}
				}
				
				// 身份证信息验证 - 当需要身份证时
				if(this.huodong_data_list.sfz == 1){
					if(this.huodong_baoming_data_add.sfz && this.huodong_baoming_data_add.sfz.length > 0){
						// 遍历所有身份证信息，检查名称和身份证号是否为空
						for(let i = 0; i < this.huodong_baoming_data_add.sfz.length; i++){
							const item = this.huodong_baoming_data_add.sfz[i];
							// 检查姓名是否为空
							if(!item[1] || item[1].trim() === ''){
								uni.showToast({
									title: '请输入第' + (i + 1) + '份的姓名',
									icon: 'none'
								})
								return;
							}
							// 检查身份证号是否为空
							if(!item[2] || item[2].trim() === ''){
								uni.showToast({
									title: '请输入第' + (i + 1) + '份的身份证号',
									icon: 'none'
								})
								return;
							}
						}
					} else {
						// 如果没有添加身份证信息
						uni.showToast({
							title: '请添加身份证信息',
							icon: 'none'
						})
						return;
					}
				}
				let fufeijifen = 0;
				//判断类型
				if(this.huodong_data_list.hdfs == 1){
					fufeijifen = 0;
				} else if(this.huodong_data_list.hdfs ==2){
					fufeijifen = 0;
				} else if(this.huodong_data_list.hdfs ==3){
					fufeijifen = 0;
				} else if(this.huodong_data_list.hdfs ==4){
					fufeijifen = 10;
				} else if(this.huodong_data_list.hdfs ==5){
					fufeijifen = 31;
				}
				
				// 创建指定格式的对象
				let sfzFormatObj = {};
				if(this.huodong_data_list.sfz == 1){
					this.huodong_baoming_data_add.sfz.forEach((item, index) => {
						  // 使用索引+1作为外层对象的键
						  sfzFormatObj[index + 1] = {
						    1: item[1] || '', //  对应键1
						    2: item[2] || '', // 对应键2
						  };
						});
				}
				// postHuodong_shenqing_api
				try {
					// 构建参数字符串，包含所有需要的字段
					let datas = "is_ajax=1&catid=1" +
						"&data[hd_id]=" + this.huodong_data_list.hd_id +
						"&data[title]=" + this.huodong_data_list.title +
						"&data[cid]=" + this.huodong_data_list.hd_id +
						"&data[buy_uid]=" + uid +
						"&data[tieid]=" + this.id +
						"&data[quanid]=" + this.cid +
						"&data[weixinhao]=" + this.huodong_baoming_data_add.weixinhao +
						"&data[shoujihaoma]=" + this.huodong_baoming_data_add.shoujihaoma +
						"&data[hdfs]=" + this.huodong_data_list.hdfs +
						"&data[hdfy]=" + this.huodong_data_list.hdfy * this.fenliang + 
						"&data[shenhe]=1" + 
						"&data[fufeijifen]=" + fufeijifen +
						"&data[feiyong]=" + this.huodong_data_list.hdfy * this.fenliang +
						"&data[huodongjifen]=" + this.huodong_data_list.huodongjifen * this.fenliang +
						"&data[jifen]=" + this.huodong_data_list.huodongjifen * this.fenliang +
						"&data[bmfl]=" + this.fenliang +
						"&data[cph]=" + this.huodong_baoming_data_add.cph;
						// 添加身份证信息到提交数据中
						if(this.huodong_data_list.sfz == 1 && this.huodong_baoming_data_add.sfz){
							datas += "&data[sfz]=" + JSON.stringify(sfzFormatObj);
						}
					
					let res = await postRequest(url,datas);
					if(res.data.code){
						uni.showToast({
							title: '报名成功',
							icon: 'none'
						})
						// 报名成功后，清空输入框
						this.huodong_baoming_data_add = {};
						this.hd_baoming_close();
						this.$emit('refreshData');
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				} catch (error) {
					console.log(error);
				}
				
				
			},
			//退出活动
			huodong_tuichu(){
				//弹出确认框
				uni.showModal({
					title: '提示',
					content: '确定退出活动吗？',
					success: (res) => {
						if (res.confirm) {
							// 确认退出
							// 调用退出活动的接口
							this.huodong_tuichu_api();
							// 接口调用成功后，关闭弹窗
							uni.hideModal();
							
						} else if (res.cancel) {
							// 取消退出
							// 不做任何操作，只是关闭弹窗
							uni.hideModal();
						}
					}
				});
			},
			//退出接口
			async huodong_tuichu_api(){
				let uid = this.$store.state.memberuid;
				let code = this.$store.state.keycode;
				// 检查是否已登录
				if (!uid || !code) {
					uni.showToast({
						icon: 'none',
						title: '请先登录',
						duration: 1000
					});
					return;
				}
				let cid = this.huodong_data_list.hd_id;
				let url = HuodongApi.postHuodong_tuichu_api(uid,code,cid);

				let datas = "is_ajax=1&catid=1" +
				"&data[hd_id]=" + this.huodong_data_list.hd_id +
				"&data[title]=" + this.huodong_data_list.title +
				"&data[cid]=" + this.huodong_data_list.hd_id +
				"&data[buy_uid]=" + uid +
				"&data[tieid]=" + this.id +
				"&data[quanid]=" + this.cid +
				"&data[hdfs]=" + this.huodong_data_list.hdfs +
				"&data[hdfy]=" + this.huodong_data_list.hdfy + 
				"&data[huodongjifen]=" + this.huodong_data_list.huodongjifen;
				try {
					let res = await postRequest(url,datas);
					if(res.data.code){
						uni.showToast({
							title: '退出成功',
							icon: 'none'
						})
						// 退出成功后，刷新接口
						this.$emit('refreshData');
						
						
						
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				} catch (error) {
					console.log(error);
				}
			},
			//报名列表按钮
			baoming_uid_list_api(id){
				this.$emit('baoming_uid_list',id);
			},
			
			// 添加身份证信息
			sfz_tianjia(){
				// 检查是否已达到最大份数
				if(this.huodong_baoming_data_add.sfz.length >= this.huodong_data_list.xzrs){
					uni.showToast({
						title: '最多只能添加' + this.huodong_data_list.xzrs + '份信息',
						icon: 'none',
						duration: 2000
					});
					return;
				}
				
				// 添加新的身份证信息项
				const newIndex = this.huodong_baoming_data_add.sfz.length;
				this.huodong_baoming_data_add.sfz.push([
					newIndex + 1, // 索引标识
					'', // 姓名
					''  // 身份证号
				]);
				
				// 延迟滚动到最新添加的项目
				setTimeout(() => {
					const element = document.getElementById('sfz_id_' + newIndex);
					if(element) {
						element.scrollIntoView({ behavior: 'smooth', block: 'end' });
					}
				}, 100);
			},
			
			// 删除身份证信息
			sfz_shanchu(index){
				// 弹出确认框
				uni.showModal({
					title: '确认删除',
					content: '确定要删除第' + (index + 1) + '份信息吗？',
					success: (res) => {
						if(res.confirm){
							// 确认删除
							this.huodong_baoming_data_add.sfz.splice(index, 1);
							// 更新剩余项的索引
							this.huodong_baoming_data_add.sfz.forEach((item, idx) => {
								item[0] = idx + 1;
							});
							uni.showToast({
								title: '删除成功',
								icon: 'none',
								duration: 1500
							});
						}
					}
				});
			}

		},mounted() {
			// 当活动需要身份证信息时，确保默认显示1份身份证信息
			this.$nextTick(() => {
				// 检查当前活动是否需要身份证信息
				const needIdCard = this.huodong_data_list && this.huodong_data_list.sfz == 1;
				// 如果需要身份证信息且当前没有身份证信息，默认添加1份
				if(needIdCard && (!this.huodong_baoming_data_add.sfz || this.huodong_baoming_data_add.sfz.length === 0)) {
					// 默认添加1份身份证信息
					this.huodong_baoming_data_add.sfz = [[
						1, // 索引标识
						'', // 姓名
						''  // 身份证号
					]];
				}
			});
			
			// 添加一个监听器，确保huodong_data_list数据加载后也能正确显示默认身份证信息
			this.$watch('huodong_data_list', (newVal) => {
				if(newVal && newVal.sfz == 1 && this.huodong_baoming_data_add.sfz.length === 0) {
					this.$nextTick(() => {
						this.huodong_baoming_data_add.sfz.push([
							1, // 索引标识
							'', // 姓名
							''  // 身份证号
						]);
					});
				}
			});
		}
	}
</script>

<style lang="scss">
	.time {
		// #ifndef APP-NVUE
		display: flex;
		// #endif
		flex-direction: row;
		align-items: center;
		&__item {
			color: red;
			font-size: 60rpx;
			text-align: center;
		}
	}
	.warp_baoming {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}
.rect_baoming {
	width: 300px;
	/*height: 300px;*/
	padding: 10px;
	background-color: #fff;
	border-radius: 10px;
}
.d-baoming-gao {
    height: 1000rpx;
    overflow: auto;
}
.d-sfz-gao {
    height: 300rpx;
    overflow: auto;
    /* 滚动条样式 */
    &::-webkit-scrollbar {
        width: 1px;
    }
    &::-webkit-scrollbar-track {
        background-color: #f5f5f5;
    }
    &::-webkit-scrollbar-thumb {
        background-color: #cccccc;
    }
}
</style>